//
//  DealerGDataFromXMLDocument.m
//  SmartRoadShow
//
//  Created by  ibokan on 10-9-21.
//  Copyright 2010 simonwang142232@gmail.com. All rights reserved.
//

#import "MyDataSource.h"
#import "GDataXMLNode.h"
#import "DomParser.h"
#import "Dealer.h"
#import "ArtEvent.h"
#import "ArtMark.h"
#import "SendHttpRequest.h"
#import "CacheManager.h"
#import "ArtTour.h"
#import "ArtClass.h"
#import "ArtRoadshowTour.h"
#import "Opinion.h"
#import "Context.h"

@implementation MyDataSource

//解析经销商
+(NSArray *) dealerGetDataFromXMLDocument:(NSString *)documentStr
{
	
	NSMutableArray *dealersArray = [[NSMutableArray alloc] init];
	
	NSError *error = nil;
	GDataXMLDocument* XMLdocument = [[GDataXMLDocument alloc] initWithXMLString:documentStr options:0 error:&error];
	
	GDataXMLElement *rootElement = [XMLdocument rootElement];
	

	NSMutableArray *array2 = [[NSMutableArray alloc] init]; //?????????
    
	[DomParser findElementsWithName:@"infos" 
					inParentElement: rootElement
						beRecursive:YES
					withResultArray:array2];
	
	for(id Dealer1 in array2)
	{
		Dealer *dealer = [[Dealer alloc] init];
		GDataXMLElement *area = [[Dealer1 elementsForName:@"area"] objectAtIndex:0];
		dealer._area = [[area stringValue] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
		
		GDataXMLElement *name = [[Dealer1 elementsForName:@"dealername"] objectAtIndex:0];
		dealer._name = [[name stringValue] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
		
		GDataXMLElement *show = [[Dealer1 elementsForName:@"show"] objectAtIndex:0];
		dealer._show = [[show stringValue] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
		
		GDataXMLElement *address = [[Dealer1 elementsForName:@"address"] objectAtIndex:0];
		dealer._address = [[address stringValue] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
		
		GDataXMLElement *phone = [[Dealer1 elementsForName:@"tel"] objectAtIndex:0];
		dealer._phone = [[phone stringValue] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
		
		GDataXMLElement *googleurl = [[Dealer1 elementsForName:@"googleurl"] objectAtIndex:0];
		dealer._googleurl = [[googleurl stringValue] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
		
		NSString *llStr = [[[Dealer1 elementsForName:@"googleposi"] objectAtIndex:0] stringValue];
		int sep = [llStr rangeOfString:@","].location;
		if (sep != 2147483647) {
			dealer._latitude = [[llStr substringToIndex:sep] floatValue];
			dealer._longitude = [[llStr substringFromIndex:sep + 1] floatValue];
		}
		
		[dealersArray addObject:dealer];
		[dealer release];
	}
	[array2 release];
	[XMLdocument release];
	return [dealersArray autorelease];
}

//artEvent
+(NSMutableArray *) artEventGetDataFromXMLDocument:(NSString *)documentStr IntoDB:(BOOL) Bool
{
	NSMutableArray *artEventArray = [[NSMutableArray alloc] init];
	NSError *error = nil;
	GDataXMLDocument* XMLdocument = [[GDataXMLDocument alloc] initWithXMLString:documentStr options:0 error:&error];

	if(XMLdocument != nil) 
	{
		GDataXMLElement *rootElement = [XMLdocument rootElement];
		
		NSInteger totalPages = [[[[[rootElement elementsForName:@"data"] objectAtIndex:0] attributeForName:@"totalPages"] stringValue] intValue];
		
		NSLog(@"totalpage = %d",totalPages);
		Context *context = [Context shareContext];
		context.artEventTotalPages = totalPages;
		
		NSMutableArray *array1 = [[NSMutableArray alloc] init];
		[DomParser findElementsWithName:@"infos" 
						inParentElement: rootElement
							beRecursive:YES
						withResultArray:array1];
		
		int i = 0;
		for(id artEvent in array1)
		{
			ArtEvent *aEvent = [[ArtEvent alloc] init];
			
			i++;
			aEvent._id = i;
			
			GDataXMLElement *newsId = [[artEvent elementsForName:@"id"] objectAtIndex:0];
			aEvent.news_id = [[[newsId stringValue] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]] intValue];
			
			GDataXMLElement *title = [[artEvent elementsForName:@"title"] objectAtIndex:0];
			aEvent._title = [[title stringValue] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
			
			GDataXMLElement *thumb = [[artEvent elementsForName:@"thumb"] objectAtIndex:0];
			aEvent._thumb = [[thumb stringValue] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
			
			GDataXMLElement *city = [[artEvent elementsForName:@"city"] objectAtIndex:0];
			aEvent._city = [[city stringValue] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
			
			GDataXMLElement *level = [[artEvent elementsForName:@"level"] objectAtIndex:0];
			aEvent._level = [[[level stringValue] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]] intValue];
			
			GDataXMLElement *start = [[artEvent elementsForName:@"starttime"] objectAtIndex:0];
			aEvent._starttime = [[start stringValue] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
			
			GDataXMLElement *end = [[artEvent elementsForName:@"endtime"] objectAtIndex:0];
			aEvent._endtime = [[end stringValue] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
			
			GDataXMLElement *address = [[artEvent elementsForName:@"address"] objectAtIndex:0];
			aEvent._address = [[address stringValue] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
			
			GDataXMLElement *tel = [[artEvent elementsForName:@"tel"] objectAtIndex:0];
			aEvent._tel = [[tel stringValue] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
			
			GDataXMLElement *posi = [[artEvent elementsForName:@"googleposi"] objectAtIndex:0];
			aEvent._googleposi = [[posi stringValue] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
			GDataXMLElement *content = [[artEvent elementsForName:@"url"] objectAtIndex:0];
			aEvent._content = [[content stringValue] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
			
			
			if (Bool) {
				if([ArtEvent findNewsId:aEvent.news_id])
				{
					[ArtEvent updateWithNewsID:aEvent.news_id 
										 Title:aEvent._title 
										 Thumb:aEvent._thumb 
										  City:aEvent._city 
										 Level:aEvent._level 
									 Starttime:aEvent._starttime 
									   Endtime:aEvent._endtime 
									   Address:aEvent._address 
										   Tel:aEvent._tel 
									Googleposi:aEvent._googleposi 
									   Content:aEvent._content];
				}
				else 
				{
					[ArtEvent insertWithNewsID:aEvent.news_id 
										 Title:aEvent._title 
										 Thumb:aEvent._thumb 
										  City:aEvent._city 
										 Level:aEvent._level 
									 Starttime:aEvent._starttime 
									   Endtime:aEvent._endtime 
									   Address:aEvent._address 
										   Tel:aEvent._tel 
									Googleposi:aEvent._googleposi 
									   Content:aEvent._content];
				}
				
			}
			
			[artEventArray addObject:aEvent];
			[aEvent release];
		}
		[array1 release];
	}
	[XMLdocument release];
    return [artEventArray autorelease];
}

//artMark
+(NSMutableArray *) artMarkGetDataFromXMLDocument:(NSString *)documentStr IntoDB:(BOOL) Bool
{
	NSMutableArray *artMarkArray = [[NSMutableArray alloc] init];
	NSError *error = nil;
	GDataXMLDocument* XMLdocument = [[GDataXMLDocument alloc] initWithXMLString:documentStr options:0 error:&error];

	if(XMLdocument != nil) 
	{
		GDataXMLElement *rootElement = [XMLdocument rootElement];
		
		NSInteger totalPages = [[[[[rootElement elementsForName:@"data"] objectAtIndex:0] attributeForName:@"totalPages"] stringValue] intValue];
		
		NSLog(@"totalpage = %d",totalPages);
		
		Context *context = [Context shareContext];
		context.artMarkTotalPages = totalPages;
		
		NSMutableArray *array1 = [[NSMutableArray alloc] init];
		[DomParser findElementsWithName:@"infos" 
						inParentElement: rootElement
							beRecursive:YES
						withResultArray:array1];
		
		for(id mark in array1)
		{
			ArtMark *artMark = [[ArtMark alloc] init];
			GDataXMLElement *artmarkId = [[mark elementsForName:@"id"] objectAtIndex:0];
			artMark.artMark_id = [[[artmarkId stringValue] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]] intValue];
			
			GDataXMLElement *newsId = [[mark elementsForName:@"news_id"] objectAtIndex:0];
			artMark.news_id = [[[newsId stringValue] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]] intValue];
			
			GDataXMLElement *title = [[mark elementsForName:@"title"] objectAtIndex:0];
			artMark._title = [[title stringValue] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
			
			GDataXMLElement *thumb = [[mark elementsForName:@"thumb"] objectAtIndex:0];
			artMark._thumb = [[thumb stringValue] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
			
			GDataXMLElement *city = [[mark elementsForName:@"city"] objectAtIndex:0];
			artMark._city = [[city stringValue] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
			
			GDataXMLElement *marktype = [[mark elementsForName:@"marktype"] objectAtIndex:0];
			artMark._marktype = [[marktype stringValue] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
			
			GDataXMLElement *level = [[mark elementsForName:@"level"] objectAtIndex:0];
			artMark._level = [[[level stringValue] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]] intValue];
			
			GDataXMLElement *address = [[mark elementsForName:@"address"] objectAtIndex:0];
			artMark._address = [[address stringValue] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
			
			GDataXMLElement *tel = [[mark elementsForName:@"tel"] objectAtIndex:0];
			artMark._tel = [[tel stringValue] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
			
			GDataXMLElement *googleposi = [[mark elementsForName:@"googleposi"] objectAtIndex:0];
			artMark._googleposi = [[googleposi stringValue] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
			
			GDataXMLElement *content = [[mark elementsForName:@"url"] objectAtIndex:0];
			artMark._content = [[content stringValue] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
			
			GDataXMLElement *pub = [[mark elementsForName:@"pubdate"] objectAtIndex:0];
			artMark._pubdate = [[pub stringValue] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
			if (artMark._pubdate == nil) {
				artMark._pubdate = @"";
			}
			
			
			if (Bool) {
				if([ArtMark findArtMarkID:artMark.artMark_id])
				{
					[ArtMark updateWithArtMarkID:artMark.artMark_id
										  NewsId:artMark.news_id 
										   Title:artMark._title 
										   Thumb:artMark._thumb 
											City:artMark._city
										Marktype:artMark._marktype 
										   Level:artMark._level 
										 Address:artMark._address 
											 Tel:artMark._tel
									  Googleposi:artMark._googleposi 
										 Content:artMark._content
										 Pubdate:artMark._pubdate];
				}
				else 
				{
					[ArtMark insertWithArtMarkID:artMark.artMark_id
										  NewsId:artMark.news_id 
										   Title:artMark._title 
										   Thumb:artMark._thumb 
											City:artMark._city
										Marktype:artMark._marktype 
										   Level:artMark._level 
										 Address:artMark._address 
											 Tel:artMark._tel
									  Googleposi:artMark._googleposi 
										 Content:artMark._content
										 Pubdate:artMark._pubdate];
				}
				
			}
			
			
			[artMarkArray addObject:artMark];
			[artMark release];
		}
		
		[array1 release];
	}
	[XMLdocument release];
	return [artMarkArray autorelease];
}



//艺术地图——艺术课堂
+(NSArray *) getArtClassInfo:(NSString *)xmlStr{
	NSError *error;
	NSMutableArray *classInfo = [[NSMutableArray alloc] init];
	GDataXMLDocument *xmlDocument = [[GDataXMLDocument alloc] initWithXMLString:xmlStr
																		options:0
																		  error:&error];
	

	if (xmlDocument != nil) 
	{
		GDataXMLElement *rootElement = [xmlDocument rootElement];
		NSMutableArray *tempArr = [[NSMutableArray alloc] init];
		[DomParser findElementsWithName:@"infos" inParentElement:rootElement
							beRecursive:YES withResultArray:tempArr];
		
		for (GDataXMLElement *element in tempArr){
			ArtClass *class = [[ArtClass alloc] init];
			class._id = [[[[[element elementsForName:@"id"] objectAtIndex:0] stringValue] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]] intValue];
			class._title = [[[[element elementsForName:@"title"] objectAtIndex:0] stringValue] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
			class._thumb = [[[[element elementsForName:@"thumb"] objectAtIndex:0] stringValue] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
			class._news_id = [[[[[element elementsForName:@"news_id"] objectAtIndex:0] stringValue] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]] intValue];
			class._description = [[[[element elementsForName:@"description"] objectAtIndex:0] stringValue] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
			class._content = [[[[element elementsForName:@"url"] objectAtIndex:0] stringValue] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
			class._pubdate = [[[[element elementsForName:@"pubdate"] objectAtIndex:0] stringValue] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
			
			[classInfo addObject:class];
			[class release];
		}
		[tempArr release];
		
	}
	[xmlDocument release];
	return [classInfo autorelease];
}

+ (NSArray *)getArtTourNews:(NSString *)xmlStr{
		
	NSError *error;
	NSMutableArray *classInfo = [[NSMutableArray alloc] init];
	GDataXMLDocument *xmlDocument = [[GDataXMLDocument alloc] initWithXMLString:xmlStr
																		options:0
																		  error:&error];
	if (xmlDocument != nil) 
	{
		GDataXMLElement *rootElement = [xmlDocument rootElement];
		NSMutableArray *tempArr = [[NSMutableArray alloc] init];
		[DomParser findElementsWithName:@"infos" inParentElement:rootElement
							beRecursive:YES withResultArray:tempArr];
		
		for (GDataXMLElement *element in tempArr){
			ArtClass *class = [[ArtClass alloc] init];
			class._id = [[[[[element elementsForName:@"id"] objectAtIndex:0] stringValue] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]] intValue];
			class._title = [[[[element elementsForName:@"title"] objectAtIndex:0] stringValue] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
			class._thumb = [[[[element elementsForName:@"thumb"] objectAtIndex:0] stringValue] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
			class._news_id = [[[[[element elementsForName:@"news_id"] objectAtIndex:0] stringValue] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]] intValue];
			class._description = [[[[element elementsForName:@"description"] objectAtIndex:0] stringValue] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
			class._content = [[[[element elementsForName:@"content"] objectAtIndex:0] stringValue] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
			class._pubdate = [[[[element elementsForName:@"pubdate"] objectAtIndex:0] stringValue] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
			
			[classInfo addObject:class];
			[class release];
		}
		[tempArr release];
		
	}
	[xmlDocument release];
	return [classInfo autorelease];
	
}


//艺术之旅 活动信息
+(NSMutableArray *) getStationInfo:(NSString *)xmlStr{
	
	[ArtTour deleteAll];
	
	NSError *error;
	NSMutableArray *stationInfo = [[NSMutableArray alloc] init];
	GDataXMLDocument *xmlDocument = [[GDataXMLDocument alloc] initWithXMLString:xmlStr
																		options:0
																		  error:&error];

	if (xmlDocument != nil) 
	{
		[CacheManager setXML:xmlStr withFileName:@"Station"];
		
		
		GDataXMLElement *rootElement = [xmlDocument rootElement];
		
		NSMutableArray *tempArr = [[NSMutableArray alloc] init];
		[DomParser findElementsWithName:@"infos" inParentElement:rootElement
							beRecursive:YES withResultArray:tempArr];
		
		int i = 0;
		for (GDataXMLElement *element in tempArr)
		{
			ArtTour *artTour = [[ArtTour alloc] init];
			
			
			artTour._id = i;
			artTour._city = [[[[element elementsForName:@"city"] objectAtIndex:0] stringValue] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
			NSString *times = [[[[element elementsForName:@"times"] objectAtIndex:0] stringValue] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
			artTour._location = [[[[element elementsForName:@"location"] objectAtIndex:0] stringValue] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];	
			artTour._address = [[[[element elementsForName:@"address"] objectAtIndex:0] stringValue] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
			artTour._thumb = [[[[element elementsForName:@"thumb"] objectAtIndex:0] stringValue] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
			artTour._mapURL = [[[[element elementsForName:@"mapUrl"] objectAtIndex:0] stringValue] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
			artTour._datepic = [[[[element elementsForName:@"datepic"] objectAtIndex:0] stringValue] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
			
			
			times = [times stringByReplacingOccurrencesOfString:@" " withString:@""];
						
			NSString *startTime = nil;
			NSString *endTime = nil;
			int mark = [times rangeOfString:@"-"].location;
			if (mark != 2147483647)
			{
				NSString *start_year = nil;
				NSString *start_month = nil;
				NSString *start_day = nil;
				
				startTime = [times substringToIndex:mark];
				start_year = [startTime substringToIndex:4];
				NSString *start_m_d = [startTime substringFromIndex:5];
				
				int point_s = [start_m_d rangeOfString:@"."].location;
				if (point_s != 2147483647)
				{
					start_month = [start_m_d substringToIndex:point_s];
					start_day = [start_m_d substringFromIndex:point_s + 1];		
					
					if (start_month.length == 1) {
						start_month = [NSString stringWithFormat:@"0%@",start_month];
					}
					if (start_day.length == 1) {
						start_day = [NSString stringWithFormat:@"0%@",start_day];
					}
				}
				artTour._starttime = [NSString stringWithFormat:@"%@-%@-%@",start_year,start_month,start_day];
				
				
				NSString *end_year = nil;
				NSString *end_month = nil;
				NSString *end_day = nil;
				endTime = [times substringFromIndex:mark + 1];
				end_year = [endTime substringToIndex:4];
				NSString *end_m_d = [endTime substringFromIndex:5];
				
				int point_e = [end_m_d rangeOfString:@"."].location;
				if (point_e != 2147483647) {
					end_month = [end_m_d substringToIndex:point_e];
					end_day = [end_m_d substringFromIndex:point_e + 1];
					
					if (end_month.length == 1) {
						end_month = [NSString stringWithFormat:@"0%@",end_month];
					}
					if (end_day.length == 1) {
						end_day = [NSString stringWithFormat:@"0%@",end_day];
					}
				}
				artTour._endtime = [NSString stringWithFormat:@"%@-%@-%@",end_year,end_month,end_day];			
				
			}
		
			[ArtTour insertWithID:i
							 City:artTour._city
						Starttime:artTour._starttime
						  Endtime:artTour._endtime
						 Location:artTour._location
							Thumb:artTour._thumb
						  Address:artTour._address
						   MapURL:artTour._mapURL
						  Datepic:artTour._datepic];
			
			[stationInfo addObject:artTour];
			[artTour release];
			i++;
		}
		[tempArr release];
		
	}
	[xmlDocument release];
	return [stationInfo autorelease];
}

+ (NSMutableArray *)getMoreOpinions:(NSString *) xmlStr{
	NSMutableArray *opinionsArr = [[NSMutableArray alloc] init];
	
	NSLog(@"%@",xmlStr);
	
	NSError *error;
	NSMutableArray *tempArr = [[NSMutableArray alloc] init];
	GDataXMLDocument *xmlDocument = [[GDataXMLDocument alloc] initWithXMLString:xmlStr
																		options:0
																		  error:&error];
	
	
	NSLog(@"error : %@",[error description]);
	NSLog(@"document : %@",xmlDocument);
	
	GDataXMLElement *rootElement = [xmlDocument rootElement];
	
	NSInteger totalPages = [[[[[rootElement elementsForName:@"data"] objectAtIndex:0] attributeForName:@"totalPages"] stringValue] intValue];
	
	NSLog(@"totalpage = %d",totalPages);
	Context *context = [Context shareContext];
	context.moreOpinionsTotalPage = totalPages;
	
	
	[DomParser findElementsWithName:@"item" inParentElement:rootElement
						beRecursive:YES withResultArray:tempArr];
	
	for (GDataXMLElement *element in tempArr){
		Opinion *opinion = [[Opinion alloc] init];
		
		opinion.itemId = [[[[element elementsForName:@"itemId"] objectAtIndex:0] stringValue] intValue];
		opinion.userId = [[[[element elementsForName:@"userId"] objectAtIndex:0] stringValue] intValue];
		opinion.user = [[[element elementsForName:@"user"] objectAtIndex:0] stringValue];
		opinion.title = [[[element elementsForName:@"title"] objectAtIndex:0] stringValue];
		opinion.city = [[[element elementsForName:@"city"] objectAtIndex:0] stringValue];
		opinion.thumb = [[[element elementsForName:@"thumb"] objectAtIndex:0] stringValue];
		opinion.fullSize = [[[element elementsForName:@"fullSize"] objectAtIndex:0] stringValue];
		opinion.addDate = [[[element elementsForName:@"addDate"] objectAtIndex:0] stringValue];
		
		NSLog(@"%d  %d  %@  %@  %@  %@",opinion.itemId,opinion.userId,opinion.user,opinion.title,opinion.city,opinion.thumb);
		
		
		[opinionsArr addObject:opinion];
		[opinion release];
	}
	[tempArr release];
	[xmlDocument release];
	return [opinionsArr autorelease];
}


@end
